/*
 *
 *  Copyright (C) 2009 UMA
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see http://www.gnu.org/licenses/. 
 *
 *  Author : Juan Pablo Mar�n Tobar <jpablomt@uma.es>
 *
 *  Version: 1.0
 */

package com.LibreGeoSocial.App.Perfil;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONStringer;

public class Response {
	
	private String mail;
	private String language;
	private String comment;
	private int question_id;
	private ArrayList<Integer> answers_id;
	
	public Response(){
		mail = "";
		language = "";
		comment = "";
		question_id = 0;
		answers_id = new ArrayList<Integer>();
	}

	public String getMail() {
		return mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public int getQuestion_id() {
		return question_id;
	}

	public void setQuestion_id(int questionId) {
		question_id = questionId;
	}

	public ArrayList<Integer> getAnswers_id() {
		return answers_id;
	}
	public String getAnswers_idArray() {
        String lista = ""+answers_id.get(0);
        for(int i =1;i<answers_id.size();i++)
        	lista = lista +","+ answers_id.get(i);
        return lista;
    }

	public void setAnswers_id(ArrayList<Integer> answersId) {
		answers_id = answersId;
	}
	
	public void setAnswer(int i){
		answers_id.add(new Integer(i));
	}
	
	public void deleteAnswer(int i){
		answers_id.remove(new Integer(i));
	}
	
	public String getJSONResponse() throws JSONException{
		JSONStringer js = new JSONStringer();
		js.object().key("question_id").value(question_id)
			.key("email").value(mail)
			.key("language").value(language)
			.key("comment").value(comment)
			.key("answers").array();
		for (Integer c: answers_id) js.object().key("code").value(c).endObject();
		js.endArray().endObject();
		return js.toString();
	}
	
}
